<html>
<head>
<link href=" https://121.123.149.199/MaxisSSO/MaxisStyle.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
var cpid='526s9943DdhkytbsH25k';
</script>
<script type="text/javascript" src=" https://121.123.149.199/MaxisSSO/maxisScript.js"></script>
</head>

<%@ page import="com.checkfree.isolutions.customer.persist.*" %>
<%@ page import="com.checkfree.isolutions.statement.*" %>
<%@ page import="com.checkfree.isolutions.statement.persist.*" %>

<%@ page import="com.checkfree.isolutions.property.Properties" %>
<%@ page import="com.checkfree.isolutions.property.PropertiesConfig" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.text.*" %>
<%@ page import="com.myebills.ebpsfrontend.cust.controller.*" %>
<%@ page import="com.myebills.ebpsfrontend.cust.maxis.*" %>
<%@ page import="com.myebills.ebpsfrontend.cust.utils.*" %>

<%@ page import="org.xml.sax.InputSource" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.lang.Exception" %>
<%@ page import="javax.xml.parsers.*" %>

<body>
<!--
... CP site webpage content code.......
-->
<div class="Maxis_style" id="MaxisDIV">
	<table class="tablestyle300">
		<tr>
			<td>
				<a id="btnSSOLogin" class="SSOLoginButtonStyle1" onclick="MaxisSSOLogin(cpid);"><span>Login</span></a>
			</td>
			<td>
				<a id="btnSSOLogout" style="display:none" class="SSOLogoutButtonStyle1" onclick="MaxisSSOLogout(cpid);"><span>Logout</span></a>
			</td>
			<td>
				<a id="btnSSORegister" class="SSORegisterButtonStyle1" onclick="MaxisSSORegister(cpid);"><span>Register</span></a>
			</td>
			<td>
				<a id="btnSSOForgotPW" class="SSOForgotPWButtonStyle1" onclick="MaxisSSOForgotPassword(cpid);"><span>Forgot Password</span></a>
			</td>
		</tr>
	</table>
</div>
<!--
... CP site webpage content code.......
-->

<%
		//Get attribute from session for the logon user
		final EbppxEcsUser ecsu = (EbppxEcsUser) session.getAttribute(EbppxConstants.ECS_USER);

		File f = new File("D:/Workspace/Maxis/EBPS/sso/data/response.xml");
		DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
		Document doc = docBuilder.parse(f);
		//Node root = doc.getDocumentElement();

		NodeList nodeList = doc.getElementsByTagName("GetLOBInfo_XMLResult");
		Node root = (Element)nodeList.item(0);

		LobOutputDao objOutput = new LobOutputDao();
		objOutput = DOMParser.retrieveValue00(root, 1);

		if(objOutput!=null){
		// Print output
		System.out.println("....Start print output....");

		System.out.println("Status = " + objOutput.getStatus());
		System.out.println("Error_Code = " + objOutput.getErrCode());
		System.out.println("Error_Msg = " + objOutput.getErrMsg());

		//ecsu.setUserId("aaa");
		//ecsu.setEmail(userId);
				System.out.println("ecsu.getUserId = " + ecsu.getUserId());
				System.out.println("ecsu.getEmail = " + ecsu.getEmail());

				System.out.println("ecsu.getEmail1 = " + ecsu.getEmail());
			ArrayList listAcc = objOutput.getAccount();
			for (int i = 0; i < listAcc.size(); i++) {
				AccountInfoDao objAccInfo = new AccountInfoDao();
				objAccInfo = (AccountInfoDao) listAcc.get(i);

				System.out.println("acctExtID = " + objAccInfo.getAcctExtID());
				String strOldAccountKey = AcctDetails.getOldAccountKey(objAccInfo.getAcctExtID());
				ecsu.setAccount(objAccInfo.getAcctExtID());
				ecsu.setOldAccount(strOldAccountKey);

				ecsu.setAccessType("S");

				ArrayList listAccDetails = objAccInfo.getAcctDetails();
				for (int j = 0; j < listAccDetails.size(); j++) {
					AccountDetailsInfoDao objAccDetailsInfo = new AccountDetailsInfoDao();
					objAccDetailsInfo = (AccountDetailsInfoDao) listAccDetails.get(j);


					System.out.println("MSISDN = " + objAccDetailsInfo.getMsisdn());
					System.out.println("ServiceStatus = " + objAccDetailsInfo.getServiceStatus());
					System.out.println("LOB = " + objAccDetailsInfo.getLob());
					System.out.println("Package = " + objAccDetailsInfo.getPackage());
					System.out.println("PrinSuppInd = " + objAccDetailsInfo.getPrinSuppInd());
					System.out.println("PostPreInd = " + objAccDetailsInfo.getPostPreInd());
					System.out.println("SSOStatus = " + objAccDetailsInfo.getSSOStatus());

					if(objAccDetailsInfo.getPrinSuppInd().equals("P")){
						ecsu.setAccessType("P");
					}
				}
			}
			System.out.println("....End print output...."+session);
			session.setAttribute(EbppxConstants.ECS_USER, ecsu);
			response.sendRedirect(response.encodeRedirectURL("CusPhoneBookList_v1r00"));
		}else{
			response.sendRedirect(response.encodeRedirectURL("CusPhoneBookList_v1r00"));
		}
%>
</body>
</html>